#example6_13.py
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
# 日期列以字符串形式读取dtype=str
date_string=np.loadtxt('stock.csv',delimiter=',',dtype=str,
                        usecols=(0,),unpack=True,skiprows=1)
# 其它列默认以浮点数形式读取
open_price=np.loadtxt('stock.csv',delimiter=',',
                        usecols=(1,),unpack=True,skiprows=1)

open_date = [datetime.strptime(d,'%Y/%m/%d').date() for d in date_string]

plt.rcParams['font.sans-serif']=['SimHei']

plt.plot_date(open_date,open_price,color='red',linestyle='--')
# 设置刻度字体大小
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
plt.title('开盘价',fontsize=15)
plt.gcf().autofmt_xdate()  #自动旋转日期标记
plt.show()

